package Stringdemo;

public class demo2 {
    public static void main(String[] args) {

        String s1 = new String("abc");
        String s2 = new String("ad");
        String s3 = new String("abcd");
        String s4 = new String("abc");
        System.out.println(s1.compareTo(s2));       //-1    s1和s2进行比较，b≠c且c>b，所以返回值是ascii值 s1-s2 = -1
        System.out.println(s1.compareTo(s3));       //-1    s1和s3比较，前面相同但是s3长度比s1大1，返回值是s1.length-s3.length
        System.out.println(s1.compareTo(s4));       //0
    }
}
